<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>表单</title>
    <link rel="stylesheet" href="__STATIC__/frame/layui/css/layui.css">
    <link rel="stylesheet" href="__STATIC__/frame/static/css/style.css">
    <link rel="icon" href="__STATIC__/frame/static/image/code.png">
</head>
<body class="body">
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">等级名称</label>
        <div class="layui-input-block">
            <input type="number" name="number" lay-verify="title" autocomplete="off" placeholder="请输入等级名称" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所需经验</label>
        <div class="layui-input-block">
            <input type="number" name="grade_experience" lay-verify="title" autocomplete="off" placeholder="请输入所需经验" class="layui-input">
        </div>
    </div>
</form>
<div style="text-align: center">
    <button class="layui-btn" id="tijiao">提交</button>
</div>
<script src="__STATIC__/frame/layui/layui.all.js" charset="utf-8"></script>
<script src="__STATIC__/js/jquery.3.3.1.min.js" charset="utf-8"></script>
<script>
$("#tijiao").click(function () {
    var $number = $("[name=number]").val();
    var $grade_experience = $("[name=grade_experience]").val();
    $.post("{:url('add/grade')}",{number:$number,grade_experience:$grade_experience},function (data) {
        if(data.code==200){
           layer.msg(data.msg);
           setTimeout(function () {
               var index = parent.layer.getFrameIndex(window.name);
               parent.layer.close(index);
           },1500);
        }else{
            layer.msg(data.msg);
        }
    })
})
</script>
</body>
</html>